<!DOCTYPE HTML>
<html lang="utf-8">
<head>
<meta charset="utf-8">
<title>驾车宝典-帖子列表</title>
<link href="${ctx}/styles/forum.css" rel="stylesheet" type="text/css">
<#include '/baseHead.ftl'>
<!--导航结束-->
<!--/{cityNo}-{cateId}-{filter}-{groupId}-{pageNumber}-{orderBy} -->
<#macro pageLink  cityNo,cateId,filter,groupId,pageNumber,orderBy>${ctx}/forum/list/${cityNo}-${cateId}-${filter}-${groupId}-${pageNumber}-${orderBy}</#macro>
<script>
	function changeOrder(select){
		window.location.href = "${ctx}/forum/list/${cityNo}-${cateId}-${filter}-0-1-"+select.value;
	}
</script>
<!--主要部分开始-->
<section id="main"><div class="bgA_01">
	
	<div class="forumPanel_01">
		<nav class="menuField">
			<ul>
				<#list  categoryList  as category>
				<#if (category_index  > 3) >
					<#break>
				</#if>
				<!-- <#macro groupDetailLink  groupId>${ctx}/group/detail/${groupId}</#macro>-->
				<li   class="link${category_index +1}"  ><a href="<@pageLink   cityNo="${cityNo}" cateId="${category.cateId}" filter="${filter}" groupId="0" pageNumber="1" orderBy="${orderBy}" /> "/>
				<em>${category.cateName!}</em><span>讨论主题：${category.totalTopicCount+500}</span><span class="count">${category.totalTopicCount+200}</span></a></li>
				</#list>
			</ul>
		</nav>
		<div class="linkField">
			<a  <#if groupId == 0 >class="on"</#if> href="<@pageLink   cityNo="${cityNo}" cateId="0" filter="${filter}" groupId="${groupId}" pageNumber="1" orderBy="${orderBy}" />">ALL</a> ｜ 
			<#list  eightGroupList as group>
			<#if (group_index  > 6) >
					<#break>
				</#if>
			<a   <#if groupId == group.groupId >class="on" </#if>
				 href = "<@groupDetailLink groupId="${group.groupId}" />"
				 >${group.groupName!}</a><#if ( group_index   == ( eightGroupList?size - 1 ))  ><#else> ｜</#if> 
			</#list>
		</div>
		<div class="pageNumField">
		<#if isLogin>
			<p class="btns">
			 	<a href="#ss" class="btn" title="点击发帖">发贴</a> 
			</p>
		</#if>
			<p>
					<#if !topicPage.firstPage>
					<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="1" orderBy="${orderBy}" />">首页</a>
					</#if>
					<#if topicPage.hasPreviousPage>
					<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${pageNumber-1}" orderBy="${orderBy}" /> ">上一页</a>
					</#if>
					<#list topicPage.getLinkPageNumbers() as item>
						<#if item_index==5> 
						</#if>
						<#if item == topicPage.thisPageNumber>
						<!--/{cityNo}-{cateId}-{filter}-{groupId}-{pageNumber}-{orderBy} -->
							<a href="javascript:;" class="on">${item}</a>
						<#else>
								<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${item}" orderBy="${orderBy}" />">${item}</a>
						</#if>
					</#list>
					<#if topicPage.hasNextPage>
					<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${pageNumber+1}" orderBy="${orderBy}" /> ">下一页</a>
					</#if>
					<#if !topicPage.lastPage>
					<a  href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${topicPage.lastPageNumber?c}" orderBy="${orderBy}" /> ">末页</a>
					</#if>
			</p>
		</div>
		<div class="listField">
			<table cellpadding="0" cellspacing="0" class="list">
				<thead>
					<tr>
						<th colspan="2">
							<span class="controls">排序：
								<select onchange="changeOrder(this);" >
									<option value='1'<#if orderBy==1>selected</#if> >最近发表</option>
									<option value='4' <#if orderBy==4>selected</#if> >最后回复</option>
									<option value='2' <#if orderBy==2>selected</#if> >回复数</option>
									<option value='3'<#if orderBy==3>selected</#if> >点击数</option>
								</select>
							<!-- </span><span class="links"><a href="#">精华</a> ｜ <a href="#">打分</a> ｜ <a href="#">推荐</a></span> -->
						</th>
						<th class="by">作者</th>
						<th class="num">回复/查看</th>
						<th class="by">最后回复</th>
					</tr>
				</thead>
			</table>
			<table cellpadding="0" cellspacing="0" class="list">
				<tbody>
				<!-- 全站置顶-->
					<#list fullSiteTopList  as topic>
					<tr>
						<td class="icn">
							<a target="_blank" class="icon" title="${topic.topicTitleAfterFilter}">
								<img  <@getTopicImage topic=topic /> width="18" height="18">
							</a>
						</td>
						<td class="new">
							<em>[<a href="<@groupDetailLink  groupId="${topic.fkGroupId}" />">${topic.groupName}</a>]</em>
							<a href="<@topicDetailLink topicId="${topic.topicId?c}"/>" class="normal" style='color:#f08200'>${topic.topicTitleAfterFilter}</a>
						</td>
						<td class="by">  
							<a href="<@userCenterLink memberId="${topic.fkCreateMemberId?c}"/>">${topic.createMemberName!}</a>
							<span>${topic.createDate?date}</span>
						</td>
						<td class="num">${topic.replyCount?c}/${topic.clickCount?c}</td>
						<td class="by">
						<@lastReply topic=topic/>
						</td>
					</tr>
					</#list>
				<!-- 分类置顶 -->
					<#list cateGoryTopList as topic>
					<tr>
						<td class="icn">
							<a target="_blank" class="icon" title="${topic.topicTitleAfterFilter}">
								<img   <@getTopicImage topic=topic />  width="18" height="18" >
							</a>
						</td>
						<td class="new">
							<em>[<a href="<@groupDetailLink  groupId="${topic.fkGroupId}" />">${topic.groupName}</a>]</em>
							<a href="<@topicDetailLink topicId="${topic.topicId?c}"/>" class="normal">${topic.topicTitleAfterFilter}</a>
						</td>
						<td class="by">
							<a href="<@userCenterLink memberId="${topic.fkCreateMemberId?c}"/>">${topic.createMemberName!}</a>
							<span>${topic.createDate?date}</span>
						</td>
						<td class="num">${topic.replyCount?c}/${topic.clickCount?c}</td>
						<td class="by">
						<@lastReply topic=topic/>
						</td>
					</tr>
					</#list>
				<!-- 普通帖子-->
					<#list topicPage.result as topic>
					<tr>
						<td class="icn">
							<a target="_blank" class="icon" title="${topic.topicTitleAfterFilter}">
								<img <@getTopicImage topic=topic />   width="18" height="18">
							</a>
						</td>
						<td class="new">
							<em>[<a href="<@groupDetailLink  groupId="${topic.fkGroupId}" />">${topic.groupName}</a>]</em>
							<a href="<@topicDetailLink topicId="${topic.topicId?c}"/>" class="normal">${topic.topicTitleAfterFilter}</a>
						</td>
						<td class="by">
							<a href="<@userCenterLink memberId="${topic.fkCreateMemberId?c}"/>">${topic.createMemberName!}</a>
							<span>${topic.createDate?date}</span>
						</td>
						<td class="num">${topic.replyCount?c}/${topic.clickCount?c}</td>
						<td class="by">
						<@lastReply topic=topic/>  
						</td>
					</tr>
					</#list>
			</table>
		</div>
		<div class="pageNumField">
			<#if isLogin>
			 <p class="btns">
				<a href="#ss" class="btn" title="点击发帖">发贴</a>
			</p>
			</#if>
			<p>
				<#if !topicPage.firstPage>
					<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="1" orderBy="${orderBy}" />">首页</a>
					</#if>
					<#if topicPage.hasPreviousPage>
					<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${pageNumber-1}" orderBy="${orderBy}" /> ">上一页</a>
					</#if>
					<#list topicPage.getLinkPageNumbers() as item>
						<#if item_index==5> 
						</#if>
						<#if item == topicPage.thisPageNumber>
						<!--/{cityNo}-{cateId}-{filter}-{groupId}-{pageNumber}-{orderBy} -->
							<a href="javascript:;" class="on">${item}</a>
						<#else>
								<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${item}" orderBy="${orderBy}" />">${item}</a>
						</#if>
					</#list>
						<#if topicPage.hasNextPage>
					<a href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${pageNumber+1}" orderBy="${orderBy}" /> ">下一页</a>
					</#if>
					<#if !topicPage.lastPage>
					<a  href="<@pageLink   cityNo="${cityNo}" cateId="${cateId}" filter="${filter}" groupId="${groupId}" pageNumber="${topicPage.lastPageNumber?c}" orderBy="${orderBy}" /> ">末页</a>
					</#if>
			</p>
		</div>
		<#if isLogin>
		<a name='ss' id='ss'></a>
		<div class="formField">
			<div class="title">
				<h2>快速发贴</h2>
			</div>
			<form id="editorForm" action="${ctx}/topic/createtopic" method="post">
			<div class="form">
				<div class="formTitle">
					<div class="select">
						<select class="slt" id="groupSelect" name="fkGroupId">
									<option value="0">选择群组</option>
									<#list allGroupList as group>
										<option value="${group.groupId?c}">${group.groupName!}</option>
									</#list>
						</select>
					</div>
					<input type="text" name="topicTitleBeforeFilter" id="topicTitleBeforeFilter" class="txt" placeholder="请输入标题,标题最大长度为30个中文字" onkeyup='calRemain();'>
					<span>还可输入 <strong id="remain">30</strong> 个字符</span>
				</div>
				<div class="formContent">
					<textarea id="content" name="topicContBeforeFilter" style="height:208px;width:908px" ></textarea>
				</div>
				<input type="hidden" name="from" id="from">
				<input type="hidden" value="1" name="topicType" id="topicType">
				<input type="hidden" value="1" name="fkTitleTypeId" id="fkTitleTypeId">
				</form>
				<!--
				<div class="formCheck">
					<input type="checkbox" id="shareToWeibo" name="shareTo" class="check"><label for="shareToWeibo">同时发布到新浪微博</label>
					<input type="checkbox" id="shareToTencent" name="shareTo" class="check"><label for="shareToTencent">同时发布到腾讯微博</label>
				</div>
				-->
				
				<div class="formBtns">
					<input type="button" class="btn btn1" onclick='checkSubmit();' value="" style='width:85px'></button>
				</div>
			</div>
		</div>
	
		</#if>
		
	</div> 
	
<#include '/commonFriendLink.ftl'>

</div></section>
<!--主要部分结束-->
<#include '/baseFoot.ftl'>
<script charset="gbk" src="${ctx}/scripts/kindeditor-min.js"></script>
<script>
	
	<#if  isLogin>
	function calRemain(){
		if ( $('#topicTitleBeforeFilter').val().length > 30 ){
			$('#remain').html("0");
			 $('#topicTitleBeforeFilter').val( $('#topicTitleBeforeFilter').val().substr(0,30) );
		}
		$('#remain').html(30 -   $('#topicTitleBeforeFilter').val().length);
	}
	function checkSubmit(){
		if ( $('#groupSelect').val() ==  0 ){
			alert("请选择群组");
			setBorder("groupSelect");
			return false; 
		}else{
			clearBorder("groupSelect");
		}
		/*
		if ( $('#topicTitleTypeSelect').val() ==  0 ){
			alert("请选择主题分类");
			setBorder("topicTitleTypeSelect");
			return false;
		}else{
			clearBorder("topicTitleTypeSelect");
		}*/
		if ( $('#topicTitleBeforeFilter').val()  ==  "" ){
			alert("请输入标题");
			setBorder("topicTitleBeforeFilter");
			return false ;
		}else{
			clearBorder("topicTitleBeforeFilter");
		}
		if ( $('#topicTitleBeforeFilter').val().length >30){
			alert("标题最多为30 个字符");
			setBorder("topicTitleBeforeFilter");
			return false ;
		}else{
			clearBorder("topicTitleBeforeFilter");
		}
		var  content = $('#content').val();
		if ( content.length <  20 ){
			alert('内容不能少于20个字');
			return ;
		}
		$('#from').val(window.location);
		document.forms["editorForm"].submit();
	}
	$(function(){
				KE.show({
				id : "content",
				imageUploadJson : '${ctx}/image/uploadimage',
					items : ['source','fontname', 'fontsize', '|', 'undo','redo','plainpaste','wordpaste','|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline','removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist','advtable','hr', '|', 'emoticons', 'image', 'link','|','flash','media'],
				resizeMode : 1,
				allowPreviewEmoticons : true,
				allowUpload : true,
				afterCreate : function(id) {
					KE.event.ctrl(document, 13, function() {
						KE.util.setData(id);
						if(checkSubmit()!=false)
							document.forms["editorForm"].submit();
					});
					KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
						KE.util.setData(id);
						if(checkSubmit()!=false)
							document.forms["editorForm"].submit();
					});
				}
				});
		});
		</#if>
</script>
</body>
</html>